import {request} from './request';

// 订单预览
export function getOrderPreview() {
    return request({
        url: '/api/orders/preview'
    })
}

// 创建订单
export function createOrder(data) {
    return request({
        url: '/api/orders',
        method: 'post',
        data
    })
}

// 订单详情
export function getOrderDetail(order) {
    return request({
        url: `/api/orders/${order}`,
        params: {
            include: 'user,orderDetails.goods'
        }
    })
}

// 订单列表
export function getOrderList(params) {
    return request({
        url: `/api/orders`,
        params
    })
}

// 物流详情
export function viewExpress(order) {
    return request({
        url: `/api/orders/${order}/express`
    })
}

// 确认收货
export function confirmOrder(order) {
    return request({
        url: `/api/orders/${order}/confirm`,
        method: 'patch'
    })
}

// 评价商品
export function commentOrder(order, data) {
    return request({
        url: `/api/orders/${order}/comment`,
        method: 'post',
        data
    })
}

// 获取支付二维码
export function payOrder(order, params) {
    return request({
        url: `/api/orders/${order}/pay`,
        params
    })
}

// 查询支付状态
export function payOrderStatus(order) {
    return request({
        url: `/api/orders/${order}/status`
    })
}
